<?php

namespace App\Services;

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;

class BaseService 
{

    public function __construct() 
    {

    }

     /**
     * 操作成功返回
     */
    protected function success($data = [], $msg = '操作成功', $code = 200)
    {
        if(empty($data)){
            $data=[];
        }
        $alert=[
            'code' => $code,
            'message' => $msg,
            'data' => $data
        ];
        echo json_encode($alert);
        exit;
    }
    protected function success1($data = [], $msg = '操作成功', $code = 200)
    {
        $alert='success';
        echo json_encode($alert);
        exit;
    }

    /**
     * 操作失败返回
     */
    protected function error($msg = '操作失败', $code = 0, $data = [])
    {
        if(empty($data)){
            $data=[];
        }
        $alert=[
            'code' => $code,
            'message' => $msg,
            'data' => $data
        ];
        echo json_encode($alert);
        exit;
    }
    protected function error1($msg = '操作失败', $code = 0, $data = [])
    {
        $alert='failure';
        echo json_encode($alert);
        exit;
    }

    
  
}
